<%@ page import="com.myx.pojo.News" %>
<%@ page import="com.myx.service.news.NewsService" %>
<%@ page import="com.myx.service.news.NewsServiceImpl" %>
<%@ page import="com.myx.tool.Constant" %>
<%@ page import="java.util.List" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>后台首页</title>
    <link type="text/css" rel="stylesheet" href="<%=request.getContextPath() %>/css/common.css"/>
</head>

<body>
<!--页面顶部-->
<%@include file="../common/header.jsp"%>

<%
    String newsIdStr = request.getParameter("newsId");
    Integer newsId = null;
    if (newsIdStr != null) {
        newsId = Integer.parseInt(newsIdStr);
    }
    NewsService newsService=new NewsServiceImpl();
    News news=null;
    if (newsId != null) {
        news=newsService.getNewsById(newsId);
    }
    if (news!=null){
%>
<!--主体-->
<div id="content" class="main-content clearfix">

    <%--    左边导航--%>
    <%@include file="../common/left.jsp"%>
    <div class="main-content-right">
        <div class="add-news">
            <h1>添加新闻</h1>
            <form action="<%=request.getContextPath()%>/ModifyNewsServlet" method="post">
                <p>分类id：<input type="text" name="categoryId" value="<%=news.getCategoryId()%>"></p>
                <p>新闻标题：<input type="text" name="newsTitle" value="<%=news.getTitle()%>"></p>
                <p>新闻摘要：<input type="text" name="newsSummary" value="<%=news.getSummary()%>"></p>
                <p>新闻内容：<textarea name="newsContent" value="<%=news.getContent()%>"></textarea></p>
                <p>图片上传：<input type="file" name="imageUpload" value="<%=news.getPicPath()%>"></p>
                <p><input type="submit" value="添加新闻"></p>
                <input type="hidden" name="newsId" value="<%=news.getId()%>">
            </form>
            <%
                }
            %>
            <span>
                <%
                    if (request.getAttribute(Constant.MODIFY_FAIL) != null) {
                        out.print(request.getAttribute(Constant.MODIFY_FAIL));
                    }
                %>

            </span>
        </div>

    </div>
</div>

<!--底部-->
<%@include file="../common/footer.jsp"%>
</body>
</html>